package com.xiaoyilin.topic;

import com.xiaoyilin.config.Config;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.CreateTopicsResult;
import org.apache.kafka.clients.admin.NewTopic;

import java.util.Collections;
import java.util.concurrent.ExecutionException;

public class TestKafkaAdminClient {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        String topic = "topic-admin";
        NewTopic newTopic = new NewTopic(topic, 4, (short) 1);
       /* Map<String , String> configs =new HashMap<>();
        configs.put ("cleanup.policy","compact");
        newTopic.configs(configs) ;*/
        AdminClient adminClient = Config.initAdminClient();
        CreateTopicsResult createTopicsResult = adminClient.createTopics(Collections.singleton(newTopic));
        createTopicsResult.all().get();
        adminClient.close();
    }


}
